leagueoflegendsfandomcom_tr-20200215-history
Modül:Base stats
local p = {} local lib = require('Module:Feature') local json = require('Module:JSON') local cmd = require('Module:Maintenance data') local userError = require('Dev:User error') local IL = require('Module:ImageLink') function p.compare(frame) local args; if frame.args nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local a,b,c= cmd.main{"PatchId"}:match"(^%.*).(^%.*).(^%.*)" s="" a=tonumber(a) b=tonumber(b) c=tonumber© local stop=false local luadata while a>=0 do if b 0 then b=24 end while b>=1 do if b 24 and c 0 then c=2 else if c 0 then c=1 end end while c>=1 do luadata = loadData(a.."."..b.."."..c) if luadata~=nil then stop=true break end c=c-1 end if stop true then break end b=b-1 end if stop true then break end a=a-1 end local championtable={} local stattable={} local resulttable={} for championname,championdata in pairs(luadata) do for stat,statdata in pairs(championdata.stats) do wikistatdata=pst2(championname,stat,frame) if wikistatdata " }" then wikistatdata=pst2(championname,"as_base",frame) end if tonumber(statdata)~=tonumber(wikistatdata) then if resulttablechampionname nil then resulttablechampionname={} stattablechampionname={} table.insert(championtable,championname) end table.insert(stattablechampionname,stat) resulttablechampionnamestat=statdata end end end table.sort(championtable) for _,championname in pairs(championtable) do table.sort(stattablechampionname) s=s..ci(championname).."\n" for _,stat in pairs(stattablechampionname) do s=s.."*"..stat.."= "..resulttablechampionnamestat.."\n" end end return "Patch Data: "..a.."."..b.."."..c.." "..s end function p.get(frame) local args; if frame.args nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local stat3 = string.lower(args1 or "as") local rangetype = args"rangetype" local sortby = args"sortby" local lvl = args"lvl" local show = tonumber(args"show" or 1) if rangetype~=nil then rangetype=string.lower(rangetype) end if sortby~=nil then sortby=string.lower(sortby) end local size = tonumber(args"size" or 5) local stat,stat2="","" if stat3 "ad" or stat3 "dam" or stat3 "attack damage" then stat="dam" stat2="AD" else if stat3 "attack speed" or stat3 "as" then stat="as" stat2="AS" else if stat3 "health" or stat3 "hp" then stat="hp" stat2="health" else if stat3 "health regeneration" or stat3 "hp5" then stat="hp5" stat2="hp5" else if stat3 "mana" or stat3 "mp" then stat="mp" stat2="mana" else if stat3 "mana regeneration" or stat3 "mp5" then stat="mp5" stat2="mp5" else if stat3 "armor" or stat3 "armor" then stat="arm" stat2="armor" else if stat3 "magic resistance" or stat3 "mr" then stat="mr" stat2="MR" else stat=stat3 stat2=stat3 end end end end end end end end if lvl~=nil and size 1 and sortby~=nil then return getstats(lvl,stat,stat2,frame,rangetype,sortby,size,show) else local s = ' " end end -- HELPER FUNCTIONS -- function getstats(lvl,stat,stat2,frame,rangetype,sortby,size,show) local a,b,c= cmd.main{"PatchId"}:match"(^%.*).(^%.*).(^%.*)" a=tonumber(a) b=tonumber(b) c=tonumber© local stop=false local luadata while a>=0 do if b 0 then b=24 end while b>=1 do if b 24 and c 0 then c=2 else if c 0 then c=1 end end while c>=1 do luadata = loadData(a.."."..b.."."..c) if luadata~=nil then stop=true break end c=c-1 end if stop true then break end b=b-1 end if stop true then break end a=a-1 end local stats={} local s="" for champname in pairs(luadata) do if (stat "mp" or stat "mp5") and pst2(champname,"resource",frame)~="" and pst2(champname,"resource",frame)~=" }" and string.lower(pst2(champname,"resource",frame))~="mana" then else if rangetype nil or string.lower(pst2(champname,"rangetype",frame)) rangetype then base=tonumber(pst2(champname,stat.."_base",frame)) or tonumber(pst2(champname,stat,frame)) xlvl=tonumber(pst2(champname,stat.."_lvl",frame)) or 0 if stat "as" then as_lvl1=tonumber(pst2(champname,"as_lvl1",frame)) or tonumber(pst2(champname,"as_base",frame)) table.insert(stats,{champname, as_lvl1+base*xlvl/100*(lvl-1)*(0.7025+0.0175*(lvl-1))}) else table.insert(stats,{champname, base+xlvl*(lvl-1)*(0.7025+0.0175*(lvl-1))}) end end end end table.sort(stats, function(a, b) return a2=1 and sortby~="bot" do if j #stats then topk="\n| "..k..". "..ci(statsj1,frame) else if statsj2 statsj+12 then topk=topk.." "..k..". "..ci(statsj1,frame) else topk=topk.."\n| "..fd(round(statsj+12)).." "..stat2 k=k+1 if k>size then break end topk="\n| "..k..". "..ci(statsj1,frame) if j 1 then topk=topk.."\n| "..fd(round(statsj2)).." "..stat2 end end end j=j-1 end j=1 k=1 while j<=#stats and sortby~="top" do if j 1 then botk="\n| "..k..". "..ci(statsj1,frame) else if statsj2 statsj-12 then botk=botk.." "..k..". "..ci(statsj1,frame) else botk=botk.."\n| "..fd(round(statsj-12)).." "..stat2 k=k+1 if k>size then break end botk="\n| "..k..". "..ci(statsj1,frame) if j #stats then botk=botk.."\n| "..fd(round(statsj2)).." "..stat2 end end end j=j+1 end k=1 while k<=size do if sortby~=nil then if sortby "top" then if topk~=nil then s=s..topk else s=s.."\n|\n|" end else if sortby "bot" then if botk~=nil then s=s..botk else s=s.."\n|\n|" end end end else if topk~=nil then s=s..topk else s=s.."\n|\n|" end if botk~=nil then s=s..botk else s=s.."\n|\n|" end end s=s.."\n|-" k=k+1 end return s end end function loadData(patchid) if exists('Module:StatTable/data/' .. patchid) and pcall(mw.loadData,'Module:StatTable/data/' .. patchid) ~= false then return mw.loadData('Module:StatTable/data/' .. patchid) end return nil end function exists(page) local sPage = page if sPage then local _, val = pcall(package.loaders2, sPage) if type(val) "function" or type(val) "string" then return true end end return false end function pst2(champion, stat, frame) return frame:expandTemplate{ title = 'Data '.. champion, args = {'pst2', stat} } end function ci(champion) return tostring(IL.champion{ "champion" = champion }) end function fd(val) val=tostring(val) if string.find(val,"0-9") nil or string.find(val,"%.") nil then return val end local a,b = val:match"(0-9*).(0-9*)" return a .. "." .. b .. "" end function round(val) local mult = 10^3 local rounding=math.floor(val * mult + 0.5) / mult return rounding end return p --